﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace CH.Easy.CMS.Domain.Seedwork
{


    public interface IRepository<TEntity> : IDisposable
        where TEntity : Entity
    {
        object Add(TEntity item);
        int Remove(Expression<Func<TEntity, bool>> s);
        int Modify(TEntity item, Expression<Func<TEntity, bool>> s, params string[] modifyColumns);
        TEntity GetByFilter(Expression<Func<TEntity, bool>> filter);
        TResult GetByFilter<TResult>(Expression<Func<TEntity, bool>> filter, Expression<Func<TEntity, TResult>> selector);
        List<TEntity> GetAll();
        List<TEntity> GetListByPage(int pageIndex, int pageSize, out int totalRecord);
        List<TEntity> GetListByPage(int pageIndex, int pageSize, Expression<Func<TEntity, bool>> filter, out int totalRecord);
        List<TResult> GetListByPage<TResult>(int pageIndex, int pageSize, Expression<Func<TEntity, bool>> filter, Expression<Func<TEntity, TResult>> selector, out int totalRecord);
        List<TResult> GetListByPage<TResult, TKey>(int pageIndex, int pageSize, Expression<Func<TEntity, bool>> filter, Expression<Func<TEntity, TResult>> selector, Expression<Func<TEntity, TKey>> orderByExpression, bool ascending, out int totalRecord);
        List<TEntity> GetListByFilter(Expression<Func<TEntity, bool>> filter);
        List<TResult> GetListByFilter<TResult>(Expression<Func<TEntity, bool>> filter, Expression<Func<TEntity, TResult>> selector);
        List<TResult> GetListByFilter<TResult, TKey>(Expression<Func<TEntity, bool>> filter, Expression<Func<TEntity, TResult>> selector, Expression<Func<TEntity, TKey>> orderByExpression, bool ascending);
    }
}
